/**
 * 
 * @param nums 
 */
function sortedSquares(nums: number[]): number[] {
    let length = nums.length-1,
        r = length,
        l = 0;
    const res = []
    while(r>=l){
        if(nums[r]*nums[r]>=nums[l]*nums[l]){
            res[length--]=nums[r]*nums[r--]
        }else{
            res[length--]=nums[l]*nums[l++]
        }
        console.log(r,l);
        
    }
    return res
};
console.log(sortedSquares([-4,-1,0,3,10]));
